//Function which runs on page load
$(document).ready(function(){
	
	//Add button click event
	$('#addNew').click(function(){
		addNewRow();
	});	
	
	//Delete button click event
	$('.deleteButton').click(function(){
		deleteRow($(this));
	});
});

/**
 * Click event function to append a new row to the tasks table
 */
function addNewRow(){	
	var numRows = $('#newTasks tr').length;

	$('#newTasks').append('<tr><td><input type="text" id="title-' + numRows + '" /></td><td><input type="text" id="description-' + numRows + '" /></td><td><a class="deleteButton" id="delete-' + numRows + '" title="Delete Task">X</a></td></tr>');
}


/**
 * Deletes the grandparent of the delete button
 */
function deleteRow(thisButton){
    thisButton.parent().parent().remove();
    return false;
}